package com.yunzong.iot.http.response;


import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.List;

/**
 * Created by shibin on 2016/12/25.
 */
public class ResponseBase<T> implements Parcelable {

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    private String code;

    private String msg;


    public T getData() {
        return data;
    }

    private T data;



    @Override
    public String toString() {
        return "{" +
                "code:\"" + code + "\"," +
                "msg:\"" + msg + "\"," +
                "data:\"{" + data + "}"
                + "}";
    }

    public ResponseBase() {
    }

    protected ResponseBase(Parcel in) {
        code = in.readString();
        msg = in.readString();
//        success = in.readByte() != 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(code);
        dest.writeString(msg);
//        dest.writeByte((byte) (success ? 1 : 0));
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<ResponseBase> CREATOR = new Creator<ResponseBase>() {
        @Override
        public ResponseBase createFromParcel(Parcel in) {
            return new ResponseBase(in);
        }

        @Override
        public ResponseBase[] newArray(int size) {
            return new ResponseBase[size];
        }
    };


    public boolean isOk() {
        return "0".equals(code);
    }
}
